{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from torch.utils.data import DataLoader, Dataset, TensorDataset\n",
    "from torch.autograd import Variable\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>text</th>\n",
       "      <th>class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>最大的优点也就是价钱比较实惠，另外有免费停车场如果住在古镇里面，白天是不允许把车开进去的。这...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>华为回应CFO孟晚舟在加拿大被捕不实报道</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>这个配置和价位真的很合适，完全够用，而且小黑的质量非常不错。</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>待机长，色彩鲜艳，屏幕大，成象效果好，我用了飞利浦535、T628等手机，在价格上比GD88...</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>之前2次是10月中旬的时候住的,记忆不是很深刻了，但是即使我再怎么不满意,我后来还是定了这里...</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16898</th>\n",
       "      <td>17126</td>\n",
       "      <td>酒店设施老化严重。作为一家五星级酒店，居然没有无烟楼层这是前台登记的时候酒店服务员说的</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16899</th>\n",
       "      <td>17127</td>\n",
       "      <td>新买来的书，刚看了一次就全都掉页了！！！！</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16900</th>\n",
       "      <td>17128</td>\n",
       "      <td>还行，就是太远了，物流走了4天</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16901</th>\n",
       "      <td>17129</td>\n",
       "      <td>中国真有恬不知耻的无良企业和人，比如6蒙牛，我去你妈！你还好意思吗？只能说国人忍耐真足够啊！...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16902</th>\n",
       "      <td>17130</td>\n",
       "      <td>服务一流，门口公交四通八达，早餐丰富，值得一住。我到厦门五天，两天锦江之星，两天厦门宾馆，都...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16903 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       index                                               text  class\n",
       "0          1  最大的优点也就是价钱比较实惠，另外有免费停车场如果住在古镇里面，白天是不允许把车开进去的。这...      2\n",
       "1          2                               华为回应CFO孟晚舟在加拿大被捕不实报道      2\n",
       "2          3                     这个配置和价位真的很合适，完全够用，而且小黑的质量非常不错。      1\n",
       "3          4  待机长，色彩鲜艳，屏幕大，成象效果好，我用了飞利浦535、T628等手机，在价格上比GD88...      0\n",
       "4          5  之前2次是10月中旬的时候住的,记忆不是很深刻了，但是即使我再怎么不满意,我后来还是定了这里...      0\n",
       "...      ...                                                ...    ...\n",
       "16898  17126        酒店设施老化严重。作为一家五星级酒店，居然没有无烟楼层这是前台登记的时候酒店服务员说的      2\n",
       "16899  17127                              新买来的书，刚看了一次就全都掉页了！！！！      2\n",
       "16900  17128                                    还行，就是太远了，物流走了4天      1\n",
       "16901  17129  中国真有恬不知耻的无良企业和人，比如6蒙牛，我去你妈！你还好意思吗？只能说国人忍耐真足够啊！...      2\n",
       "16902  17130  服务一流，门口公交四通八达，早餐丰富，值得一住。我到厦门五天，两天锦江之星，两天厦门宾馆，都...      1\n",
       "\n",
       "[16903 rows x 3 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_set = pd.read_table('dataset/train_sentiment.txt', sep='\\t')\n",
    "train_set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>text</th>\n",
       "      <th>class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>于山宾馆服务非常差,是我从未见过的恶劣.柜台动作慢,态度凶,脸色臭,房间没空调又冷又潮,餐厅...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>酒店设施陈旧，估计已经10年没有更新。壁纸、浴缸漆面剥落，马桶盖已损坏，空调系统基本瘫痪，噪...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>楚辞文化知识的学习和研究是大学语文普遍涉及的领域屈原所代表的时代精神值得后人深思和学习此书是...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>总体感觉还不错。房间很干净、简洁。网上所披露的位于海河最美的一段，特意要了6层的房间，可是却...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>linux改xp花了一下午时间。散热不好，cpu温度就没下过50，玩游戏能上70，比较吓人。...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3598</th>\n",
       "      <td>4183</td>\n",
       "      <td>在当当买这本书还是物有所值。暮光之城系列中最后也是最厚的一本，让我等了好久，终于等到了。作者...</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3599</th>\n",
       "      <td>4184</td>\n",
       "      <td>住了一次，还算可以。不过携程的房间一向不好</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3600</th>\n",
       "      <td>4185</td>\n",
       "      <td>好商家，好服务，好快速，好美的，好质量，好实惠，期待安装后淋浴好舒服了</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3601</th>\n",
       "      <td>4186</td>\n",
       "      <td>扩展口太少，USB接口位置全在左面，设计不太人性化，和送的散热垫不配套散热垫的USB口都在右...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3602</th>\n",
       "      <td>4187</td>\n",
       "      <td>很一般。性价比很差。跟上海的快捷酒店相比，价格贵，服务差外面空气不错。但是内部装修亟待改善窗...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3603 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      index                                               text  class\n",
       "0         1  于山宾馆服务非常差,是我从未见过的恶劣.柜台动作慢,态度凶,脸色臭,房间没空调又冷又潮,餐厅...      2\n",
       "1         2  酒店设施陈旧，估计已经10年没有更新。壁纸、浴缸漆面剥落，马桶盖已损坏，空调系统基本瘫痪，噪...      2\n",
       "2         3  楚辞文化知识的学习和研究是大学语文普遍涉及的领域屈原所代表的时代精神值得后人深思和学习此书是...      1\n",
       "3         4  总体感觉还不错。房间很干净、简洁。网上所披露的位于海河最美的一段，特意要了6层的房间，可是却...      1\n",
       "4         5  linux改xp花了一下午时间。散热不好，cpu温度就没下过50，玩游戏能上70，比较吓人。...      2\n",
       "...     ...                                                ...    ...\n",
       "3598   4183  在当当买这本书还是物有所值。暮光之城系列中最后也是最厚的一本，让我等了好久，终于等到了。作者...      0\n",
       "3599   4184                              住了一次，还算可以。不过携程的房间一向不好      1\n",
       "3600   4185                好商家，好服务，好快速，好美的，好质量，好实惠，期待安装后淋浴好舒服了      1\n",
       "3601   4186  扩展口太少，USB接口位置全在左面，设计不太人性化，和送的散热垫不配套散热垫的USB口都在右...      2\n",
       "3602   4187  很一般。性价比很差。跟上海的快捷酒店相比，价格贵，服务差外面空气不错。但是内部装修亟待改善窗...      2\n",
       "\n",
       "[3603 rows x 3 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_set = pd.read_table('dataset/test_sentiment.txt', sep='\\t')\n",
    "test_set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# conda environments:\n",
      "#\n",
      "base                     /home/spence/anaconda3\n",
      "bert                     /home/spence/anaconda3/envs/bert\n",
      "classifier               /home/spence/anaconda3/envs/classifier\n",
      "ner                      /home/spence/anaconda3/envs/ner\n",
      "news                     /home/spence/anaconda3/envs/news\n",
      "paddle                   /home/spence/anaconda3/envs/paddle\n",
      "pytorch               *  /home/spence/anaconda3/envs/pytorch\n",
      "qa                       /home/spence/anaconda3/envs/qa\n",
      "research                 /home/spence/anaconda3/envs/research\n",
      "tflow                    /home/spence/anaconda3/envs/tflow\n",
      "weibo                    /home/spence/anaconda3/envs/weibo\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!conda info -e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
